package com.macaline.service.impl.perssion;

import com.macaline.entity.Permission;
import com.macaline.mapper.PermissionMapper;
import com.macaline.service.perssion.PermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PermissionServiceimpl implements PermissionService{
	
	@Resource
	PermissionMapper permissionMapper;


	/**
	 * 通过id查找权限信息
	 * @param id 需要查询的权限的id
	 * @return
	 */
	@Override
	public Permission queryById(Integer id) {
		Permission permission = permissionMapper.queryById(id);
		if(permission == null){
			return null;
		}
		return permission;
	}

	/**
	 * 添加权限信息
	 * @param permission 所添加的权限信息的实体类
	 * @return
	 */
	@Override
	public int addPermisson(Permission permission) {
		return permissionMapper.insert(permission);
	}

    @Override
    public List<Permission> getPermissionListByIds(List idList) {
		if(idList == null || idList.size() == 0){
			return null;
		}
		List list = permissionMapper.selectBatchIds(idList);
		return list;
    }

	@Override
	public List<Permission> getAllPermissionList() {
		return permissionMapper.getAllPermissionList();
	}

}
